ARG PHP_VERSION
FROM ${PHP_VERSION}

ARG TZ
ARG PHP_VERSION
ARG CONTAINER_PACKAGE_URL
#ARG PHP_INI_DIR=/usr/local/etc/php/php.ini

#install composer

#WORKDIR /var/www/docker/script

COPY composer /usr/local/bin/

ADD sources.list /etc/apt/

RUN composer config -g repo.packagist composer https://packagist.phpcomposer.com

RUN apt-get update \
    && apt-get install -y cron \
    && apt-get install -y libzip-dev \
    && apt-get install -y zlib1g-dev \
    && apt-get install -y libpng-dev libjpeg-dev libfreetype6-dev \
    && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-png-dir=/usr/include \
        && docker-php-ext-install -j$(nproc) gd \
    && docker-php-ext-install zip \
    #&& docker-php-ext-install -j$(nproc) iconv \
    #&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
    && docker-php-ext-install pdo_mysql \
    && docker-php-ext-install mysqli \
    && apt-get install -y libmagickwand-dev --no-install-recommends && rm -rf /var/lib/apt/lists/*

RUN printf "\n" | pecl install imagick
RUN docker-php-ext-enable imagick

#RUN docker-php-ext-install pdo_mysql
#RUN docker-php-ext-install mysqli

RUN echo $TZ

#php container timezone
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

#setting timezone for php
RUN printf "[PHP]\ndate.timezone = '$TZ'\n" > /usr/local/etc/php/conf.d/tzone.ini

WORKDIR /var/www/docker/app
